#!usr/bin/python
# -*- coding: UTF-8 -*-
class Turtle:
    def __init__(self, x):
        self.num = x

class Fish:
    def __init__(self, x):
        self.num = x

class Pool:
    def __init__(self, x, y):
        self.turtle = Turtle(x)
        self.fish = Fish(y)

    def print_num(self):
        print('水池里总共有乌龟 %d 只， 小鱼 %d 条! ' % (self.turtle.num, self.fish.num))

pool = Pool(1, 10)
pool.print_num()

class C:
    count = 0

a = C()
b = C()
c = C()

print(a.count)
print(b.count)
print(c.count)
c.count += 10
print(c.count)

print(a.count)
print(b.count)
print(C.count)

C.count += 100
print(a.count)
print(b.count)
print(c.count)


class C:
    def x(self):
        print('X-man')
c = C()
c.x()
c.x = 1
print(c.x)
#c.x() 报错， TypeError: 'int' object is not callable
'''
不要试图在一个类里边定义出所有的属性和方法，应该利用继承和组合机制来进行扩展
用不同的词性命名，如属性名用名词，方法名用动词
'''
class BB:
    def printBB():
        print('no zuo no die')
BB.printBB() #可以

bb = BB()
#bb.printBB() #报错,因为调用的时候会实例化,bb.printBB(bb)

class CC:
    def setXY(self, x, y):
        self.x = x
        self.y = y

    def printXY(self):
        print(self.x, self.y)

dd = CC()
print(dd.__dict__) #没东西

print(CC.__dict__) #有东西

d1 = dd.setXY(4,5)
print(dd.__dict__)
print(CC.__dict__)

del CC #干掉CC对象，就不能实例化了

print('xy')
dd.printXY()




